
<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList"
      >
        <template slot="menuLeft">
          <el-button type="primary" size="small" @click="confirm">确认</el-button>
          <el-button type="primary" size="small" @click="handleExport">导出</el-button>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import baseCrud from '@/mixins/base-crud'
import {
  confirmBatch,
} from "@/api/subway/swtkblackqingfen";

export default {
  name: "swtkblackqingfen",
  mixins: [baseCrud('subway/swtkblackqingfen')],
  data() {
    return {
      params: {
        handleStatus: '2'
      }
    }
  },
   // 自定义按钮权限初始化
  created() {
    this.queren_btn = this.permissions["st_swtkblack_confirmBatch"];
  },
  computed: {
    permissionList() {
      return {
        addBtn: this.vaildData(this.permissions.st_swtkblack_add, false),
        delBtn: this.vaildData(this.permissions.st_swtkblack_del, false),
        editBtn: this.vaildData(this.permissions.st_swtkblack_edit, false)
      };
    }
  },
  methods: {
    confirm() {
      let tableSelect = this.$refs.crud.tableSelect
      if (tableSelect.length < 1) {
        this.$message.info("请选择要确认的记录");
        return false;
      }
      let ids = [];
      for (const table of tableSelect) {
        if (table.blackStatus == "1") {
          this.$message.error("请检查勾选项，只能确认未拉黑的数据。");
          return false;
        }
        ids.push(table);
      }
      confirmBatch(ids)
        .then(data => {
          this.$message.success("拉黑成功");
          this.getList(this.page);
        })
        .catch(() => {
        });
    },
  }
};
</script>
